home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
FromTheMag
/
JW FLV MEDIA PLAYER 4.2
/
mediaplayer.exe
/
player.swf
/
scripts
/
com
/
jeroenwijering
/
player
/
SPLoader.as
< prev
next >
Wrap
Text File
|
2008-11-04
|
5KB
|
171 lines
package com.jeroenwijering.player
{
import com.jeroenwijering.events.SPLoaderEvent;
import com.jeroenwijering.utils.Draw;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.system.SecurityDomain;
public class SPLoader extends EventDispatcher
{
private var done:Number;
private var loader:Loader;
private var basedir:String = "http://plugins.longtailvideo.com/";
private var player:MovieClip;
public function SPLoader(param1:MovieClip)
{
basedir = "http://plugins.longtailvideo.com/";
super();
player = param1;
}
public function loadSkin(param1:String = null) : void
{
if(param1)
{
loadSWF(param1,true);
}
else
{
hideElements(player.skin);
dispatchEvent(new SPLoaderEvent(SPLoaderEvent.SKIN));
}
}
private function skinError(param1:IOErrorEvent = null) : void
{
player.skin = player["player"];
hideElements(player.skin);
dispatchEvent(new SPLoaderEvent(SPLoaderEvent.SKIN));
}
private function pluginHandler(param1:Event) : void
{
var evt:Event = param1;
try
{
evt.target.content.initializePlugin(player.view);
evt.target.loader.visible = true;
}
catch(err:Error)
{
player.view.sendEvent("TRACE"," plugin: " + err.message);
}
--done;
if(done == 0)
{
dispatchEvent(new SPLoaderEvent(SPLoaderEvent.PLUGINS));
}
}
private function hideElements(param1:MovieClip) : void
{
var _loc2_:Number = NaN;
_loc2_ = 0;
while(_loc2_ < param1.numChildren)
{
param1.getChildAt(_loc2_).visible = false;
_loc2_++;
}
}
public function loadPlugins(param1:String = null) : void
{
var _loc2_:Array = null;
var _loc3_:Number = NaN;
if(param1)
{
_loc2_ = param1.split(",");
done = _loc2_.length;
_loc3_ = 0;
while(_loc3_ < _loc2_.length)
{
loadSWF(_loc2_[_loc3_],false);
_loc3_++;
}
}
else
{
dispatchEvent(new SPLoaderEvent(SPLoaderEvent.PLUGINS));
}
}
private function pluginError(param1:IOErrorEvent) : void
{
player.view.sendEvent("TRACE"," plugin: " + param1.text);
--done;
if(done == 0)
{
dispatchEvent(new SPLoaderEvent(SPLoaderEvent.PLUGINS));
}
}
private function skinHandler(param1:Event) : void
{
if(param1.target.content["player"])
{
player.skin = MovieClip(param1.target.content["player"]);
Draw.clear(player);
player.addChild(player.skin);
hideElements(player.skin);
dispatchEvent(new SPLoaderEvent(SPLoaderEvent.SKIN));
}
else
{
skinError();
}
}
public function loadSWF(param1:String, param2:Boolean) : void
{
var _loc3_:Loader = null;
var _loc4_:LoaderContext = null;
if(param1.substr(-4) != ".swf")
{
param1 += ".swf";
}
_loc3_ = new Loader();
if(param2)
{
_loc3_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,skinError);
_loc3_.contentLoaderInfo.addEventListener(Event.INIT,skinHandler);
}
else
{
player.skin.addChild(_loc3_);
_loc3_.visible = false;
_loc3_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,pluginError);
_loc3_.contentLoaderInfo.addEventListener(Event.INIT,pluginHandler);
}
if(player.loaderInfo.url.indexOf("http") == 0)
{
_loc4_ = new LoaderContext(true,ApplicationDomain.currentDomain,SecurityDomain.currentDomain);
if(param2)
{
_loc3_.load(new URLRequest(param1),_loc4_);
}
else
{
_loc3_.load(new URLRequest(basedir + param1),_loc4_);
}
}
else
{
_loc3_.load(new URLRequest(param1));
}
}
}
}